import time

from memory_profiler import profile

import cv2
import numpy as np
from src.canny import canny_detect
from src.greedy_rrt_frontier_detect import greedy_rrt_frontier_detect
from src.multi_greedy_rrt_frontier_detect import multi
from src.rrt_path_plan import rrt_path_detect
from src.rrt_frontier_detect import rrt_frontier_detect
from src.multi_rrt_frontier_detect import multi_rrt
from src.wavefront import wavefront_detect
# from src.test import wt

if __name__ == '__main__':
    # img_path = '../img/internet.jpg'
    # img_path = '../img/stillness_right2.jpg'
    # img_path = '../img/intel/intel0001.png'
    # img_path = '../img/intel/intel0002.png'
    # img_path = '../img/intel/intel0005.png'
    # img_path = '../img/intel/intel0015.png'

    # img_path = '../img/DM/DM00X6.png'
    # img_path = '../img/DM/DM00X10.png'
    # img_path = '../img/DM/DM00X13.png'
    img_path = '../img/DM/DM00X20.png'
    #
    # 运行10次
    # for i in range(10):
    #     # 使用该函数
    #     print(f"运行次数: {i+1} 次")
    #     start_time = time.perf_counter()
    #     # size = 0
    #     # size = canny_detect(img_path)
    #     # rrt_path_detect(img_path,(600, 520),(600,540))
    #     # size = rrt_frontier_detect(img_path,(600, 520),True) #aces
    #     # size = rrt_frontier_detect(img_path,(220, 95),True) #intel
    #     size = multi_rrt(img_path,(2000, 4000),True) #DM
    #     # size = greedy_rrt_frontier_detect(img_path,(600, 520),True) #aces
    #     # size = greedy_rrt_frontier_detect(img_path,(220, 95),True) #intel
    #     # size = greedy_rrt_frontier_detect(img_path,(2000, 4000),True) #DM
    #     # size = multi(img_path,(220, 95),True) #intel
    #     # size = multi(img_path,(2000, 4000),True) #DM
    #     # size = wavefront_detect(img_path)
    #     # wt(img_path)
    #     print("边界数量为：",size)
    #     end_time = time.perf_counter()
    #     print(f"函数运行时间: {end_time - start_time} 秒")

    # 运行10次
    for i in range(10):
        # 使用该函数
        print(f"XXXX运行次数: {i + 1} 次")
        start_time = time.perf_counter()

        # img_path = '../img/DM/DM00X20.png'
        # size = multi(img_path,(2000, 4000),True) #DM
        # size = multi_rrt(img_path,(2000, 4000),True) #DM

        img_path = '../img/intel/intel0015.png'
        # size = greedy_rrt_frontier_detect(img_path, (220, 95), True)  # intel
        size = rrt_frontier_detect(img_path, (220, 95), True)  # intel

        print("边界数量为：", size)
        end_time = time.perf_counter()
        print(f"函数运行时间: {end_time - start_time} 秒")

    # 运行10次
    for i in range(10):
        # 使用该函数
        print(f"XXX运行次数: {i + 1} 次")
        start_time = time.perf_counter()

        # img_path = '../img/DM/DM00X13.png'
        # size = multi(img_path, (2000, 4000), True)  # DM
        # size = multi_rrt(img_path,(2000, 4000),True) #DM

        img_path = '../img/intel/intel0005.png'
        # size = greedy_rrt_frontier_detect(img_path, (220, 95), True)  # intel
        size = rrt_frontier_detect(img_path, (220, 95), True)  # intel

        print("边界数量为：", size)
        end_time = time.perf_counter()
        print(f"函数运行时间: {end_time - start_time} 秒")

    # 运行10次
    for i in range(10):
        # 使用该函数
        print(f"XX运行次数: {i + 1} 次")
        start_time = time.perf_counter()

        # img_path = '../img/DM/DM00X10.png'
        # size = multi(img_path, (2000, 4000), True)  # DM
        # size = multi_rrt(img_path, (2000, 4000), True)  # DM

        img_path = '../img/intel/intel0002.png'
        # size = greedy_rrt_frontier_detect(img_path, (220, 95), True)  # intel
        size = rrt_frontier_detect(img_path, (220, 95), True)  # intel

        print("边界数量为：", size)
        end_time = time.perf_counter()
        print(f"函数运行时间: {end_time - start_time} 秒")

        # 运行10次
    for i in range(10):
        # 使用该函数
        print(f"X运行次数: {i + 1} 次")
        start_time = time.perf_counter()

        # img_path = '../img/DM/DM00X6.png'
        # size = multi(img_path, (2000, 4000), True)  # DM
        # size = multi_rrt(img_path,(2000, 4000),True) #DM

        img_path = '../img/intel/intel0001.png'
        # size = greedy_rrt_frontier_detect(img_path, (220, 95), True)  # intel
        size = rrt_frontier_detect(img_path, (220, 95), True)  # intel

        print("边界数量为：", size)
        end_time = time.perf_counter()
        print(f"函数运行时间: {end_time - start_time} 秒")